/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package comandaXM.utils;

import java.awt.Color;
import javax.swing.JLabel;

/**
 *
 * @author xmarti
 */
public class JLabelXM extends JLabel {
    private String texte=""; 
    private String filtre=""; 
    private String error=""; 
    public JLabelXM (){
        super(); 
    }
    public JLabelXM(String texte, String filtre, String error){
        this.texte= texte; 
        this.filtre= filtre; 
        this.error= error;         
        setText(); 
    }


    public void setFiltre(String filtre) {
        this.filtre = filtre;
        setText(); 
    }


    public void setError(String error) {
        this.error = error;
        setText(); 
    }

    public void setTexte(String texte) {
        this.texte = texte;        
        this.error=""; 
        setText(); 
    }
    private void setText () {
        String temp=""; 
        boolean isParametre=false; 
        temp= texte; 
        if (filtre.length()>0 ){
            isParametre=true; 
            this.setForeground(Color.blue);
            temp= temp+ "(Filtre="+filtre  ;
        }
        if (error.length()>0 ){
            isParametre=true;
            this.setForeground(Color.red);
            if (filtre.length()==0 ){
                temp= temp+ "(ERROR="+error;
            }else{
                temp= temp+"; ERROR=" + error; 
            }
        }
        if (isParametre){
            temp= temp + ")";            
        } else{
            this.setForeground(Color.BLACK);
        }
        this.setText(temp);
        
    }
    
}
